app.controller('brandController' ,function($scope,$controller,brandService){
    //读取列表数据绑定到表单中
    $controller('baseController',{$scope:$scope});

    $scope.findAll=function(){
        brandService.findAllservice().success(

            function(response){

                $scope.list=response;
            }
        );


    }
    //实现模糊查询
    $scope.searchEntity={};
    $scope.search=function (page,rows) {

        brandService.serachService(page,rows,$scope.searchEntity).success(
            function (data) {


                $scope.paginationConf.totalItems=data.total;
                $scope.list=data.rows;
            }
        )
    }
    // 保存方法

    $scope.brand={};
    $scope.save=function () {
        debugger;
        brandService.save($scope.brand).success(
            function (response) {
                if(response.success){
                    $scope.reloadList();
                }else{
                    alert("添加失败");
                }
            }
        );
    }
    //回显
    $scope.findOne=function (id) {
        brandService.findOne(id).success(
            function (response) {
                $scope.brand=response;
            }
        )
    }

    $scope.delAll=function () {
        brandService.del($scope.ids).success(function (response) {
            if(response.success){
                $scope.reloadList();
            }else{
                alert("删除失败");
            }
        });
    }
    //全选
    $scope.selectAll=function () {

        if(!$scope.box){

            for(var i=0;i<$scope.list.length;i++){
                $scope.list[i].ck=true;
            }
        }else{
            for(var i=0;i<$scope.list.length;i++){
                $scope.list[i].ck=false;
            }
        }
    }
    //反选
    $scope.SelectElse=function () {
        for(var i=0;i<$scope.list.length;i++){
            $scope.list[i].ck=!$scope.list[i].ck;
        }
    }
    //全不选
    $scope.deSelectAll=function () {
        for(var i=0;i<$scope.list.length;i++){
            $scope.list[i].ck=false;
        }
    }
    //导出
    $scope.daochu=function () {
       location.href="../brand/daochu.do";
    }

});